# coding: utf8
# try something like
def index(): 
    return dict()

def add():
    if request.post_vars:   
        vars = request.post_vars
        db.tags.insert(name = vars.name)
        return T("done")
    else:
        return dict()



def update():
    if request.post_vars:
        db(db.tags.id == request.args[0]).update(
        name = request.post_vars.name)
        return T("done")
    else:
        tag = db.tags[request.args[0]]
        if not tag: return "tag not found!"
        return dict(tag = tag)



def read():
    tag = db(db.tag.name == request.args[0]).select()
    if not tag: return "tag not found"
    return dict(tag = tag)



def delete():
    db(db.tags.name == request.args[0]).delete()
    return T("done")



def list():
    tags = db().select(db.places.ALL)
    return dict(tags = tags)
